import { UserMoneyCardStatus } from "@/pages/normal/normalList/detail"
import request from "@/utils/request"

/** 优惠券类型 */
export enum MoneyCardTemplateInfoType {
  折扣券 = 1,
  抵用券 = 2,
}

/** 优惠券使用类型 */
export enum MoneyCardTemplateCutType {
  总费用 = 1,
  服务费 = 2,
  电费 = 3,
}

/** 优惠券状态 */
export enum MoneyCardTemplateStatus {
  上架中 = 1,
  待上架 = 2,
}

export interface QueryMoneyCardTemplateListParams extends PaginationParams {
  title?: string
}

export interface MoneyCardTemplate {
  id: number
  title: string
  /** 有效天数 */
  expireDay: number
  /** 面额 */
  totalM: number
  /** 面额 新建时使用 */
  fullMoney: number
  /** 制卡数量 */
  totalNum: number
  /** 适用场站 id */
  stationIds: string
  /** 描述 */
  commend: number
  createTime: number
  stations: {station_name: string}[]
}

export async function queryMoneyCardTemplateList(params: QueryMoneyCardTemplateListParams) {
  return request<MoneyCardTemplate[]>('/app/manager/moneyModuleList', {
    data: params,
  })
}

export async function addMoneyCardTemplateTemplate(params: Partial<MoneyCardTemplate>) {
  return request('/app/manager/addMoneyModule', {
    data: params,
  })
}

export async function delMoneyCardTemplate(params: {
  id: number, 
}) {
  return request('/app/manager/statusMoneyModule', {
    data: params,
  })
}

export async function makeCardBatch(params: {
  id: number, num: number
}) {
  return request('/app/manager/moneyModule/batch', {
    data: params,
  })
}

export async function getStationsById(params: {
  infoId: number
}) {
  return request('/app/manager/moneyModule/stationList', {
    data: params,
  })
}

export interface QueryMoneyCardListParams extends PaginationParams {
  infoId?: number
  userId?: string
  status?: UserMoneyCardStatus
}
export interface MoneyCard {
  cardCode: string
  createTime: number
  /** 有效天数 */
  expireDay: number
  /** 已使用金额 */
  cutMoney: number
  /** 卡面额 */
  fullMoney: number
  id: number
  nickname: string
  telephone: string
  title: string
}
export async function queryMoneyCardList(params: QueryMoneyCardListParams) {
  return request<MoneyCard[]>('/app/manager/moneyCardList', {
    data: params,
  })
}

export async function queryDealRecordList(params: any) {
  return request<any[]>('/app/manager/cardRecordList', {
    data: params,
  })
}

export async function delMoneyCard(params: any) {
  return request('/app/manager/statusMoneyCard', {
    data: params,
  })
}
